#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include "list.h"
using namespace std;

struct Date
{
public:
	Date(size_t year = 1, size_t month = 1, size_t day = 1)
		: _year(year)
		, _month(month)
		, _day(day)
	{}

	size_t _year;
	size_t _month;
	size_t _day;
};

void testList1()
{
	zhang::list<int> lt1;

	lt1.push_back(1);
	lt1.push_back(2);
	lt1.push_back(3);

	int arr[5] = { 1,2,3,4,5 };
	zhang::list<int> lt2(arr, arr + 5);

	zhang::list<int>::iterator it = lt2.begin();
	while (it != lt2.end())
	{
		cout << *it << " ";
		++it;
	}
	cout << endl;

	zhang::list<int> lt3;
	lt3 = lt2 = lt1;
}

void testList2()
{
	zhang::list<int> lt1;

	lt1.push_back(1);
	lt1.push_back(2);
	lt1.push_back(3);

	zhang::list<int> lt2(lt1);

}

void testList3()
{
	zhang::list<int> lt1;

	lt1.push_back(1);
	lt1.push_back(2);
	lt1.push_back(3);

	auto pos = ++lt1.begin();
	pos = lt1.insert(pos, 10);
	pos = lt1.insert(pos, 20);

	pos = lt1.erase(pos);
	pos = lt1.erase(pos);
}

void testList4()
{
	zhang::list<int> lt1;

	lt1.push_back(1);
	lt1.push_back(2);
	lt1.push_back(3);
	lt1.push_front(1);
	lt1.push_front(2);
	lt1.push_front(3);
	lt1.Print();

	lt1.pop_back();
	//lt1.pop_back();
	lt1.Print();

	lt1.pop_front();
	//lt1.pop_front();
	lt1.Print();
}

void testList5()
{
	zhang::list<Date> lt1;
	lt1.push_back(Date(2023, 3, 26));
	lt1.push_back(Date(2023, 4, 27));
	lt1.push_back(Date(2023, 5, 28));

	auto it = lt1.begin();
	while (it != lt1.end())
	{
		cout << it->_year << "/" << it->_month << "/" << it->_day << endl;
		++it;
	}
}

void testList6()
{
	zhang::list<int> lt1;

	lt1.push_back(1);
	lt1.push_back(2);
	lt1.push_back(3);
	lt1.push_back(4);
	lt1.push_back(5);
	lt1.push_back(6);
	lt1.push_back(7);

	lt1.resize(4);
	lt1.Print();

	lt1.resize(10, 10);
	lt1.Print();
}

void testList7()
{
	zhang::list<int> lt1;

	lt1.push_back(1);
	lt1.push_back(2);
	lt1.push_back(3);
	lt1.push_back(4);
	lt1.push_back(5);
	lt1.push_back(6);
	lt1.push_back(7);

	zhang::list<int>::reverse_iterator rit = lt1.rbegin();
	while (rit != lt1.rend())
	{
		cout << *rit << " ";
		++rit;
	}
}

int main()
{
	testList7();
	return 0;
}